import { createRouter, createWebHistory } from 'vue-router'
import { useGuard } from './guard'
import routes from './routes'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: routes,
  scrollBehavior: () => ({ left: 0, top: 0, behavior: 'smooth' })
})

// 路由守卫
useGuard(router)

// 挂载路由模块
const setupRouter = (app) => {
  app.use(router)
}

export { router, setupRouter }
